package com.hjq.mallsearch.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @auther HJQ
 * springboot配置es的方法
 * 1.引入依赖
 * 2.编写配置，在IOC容器中创建RestHighLevelClient
 * */
@Configuration
public class MallElasticSearchConfig {
    public static final RequestOptions REQUEST_OPTION ;
    static{
        RequestOptions.Builder builder=RequestOptions.DEFAULT.toBuilder();
        REQUEST_OPTION=builder.build();
    }
    @Bean
    public RestHighLevelClient esRestClient(){
        RestClientBuilder builder = RestClient.builder(new HttpHost("192.168.182.129", 9200, "http"));

        return new RestHighLevelClient(builder);
    }
}
